package lev01_beginnerClass.class04_randToRand;

import java.lang.reflect.Array;
import java.util.Arrays;

public class L02_RandToRand3_19to20_56 {

    public static void main(String[] args) {
        int[] count = new int[37];
        for(int i = 0;i < 1000000;i++){
            count[f20_56()-20]++;
        }
        System.out.println(Arrays.toString(count));
    }

    private static int f3_19(){
        return (int)(Math.random()*17)+3;
    }

    /**
     * 3-10 return 0 12-19 return 1 ; 11 try again
     * @return
     */
    public static int f01(){
        int ans = 0;
        do{
            ans = f3_19();
        }while (ans == 11);
        return ans <11? 0:1;
    }

    public static int f0_36(){
        int ans = 0;

        do {
            ans = (f01() << 5) + (f01()<<4)+(f01()<<3)+(f01()<<2)+(f01()<<1)+f01();
        }while (ans > 36);
        return ans;
    }

    public static int f20_56(){
        return f0_36()+20;
    }
}
